package org.raymond.iworks.gateway;

import lombok.extern.slf4j.Slf4j;
import org.raymond.iworks.core.listener.AppPropertiesPreparedListener;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;

import java.net.InetAddress;
import java.net.UnknownHostException;

@Slf4j
@ServletComponentScan
@EnableFeignClients
@EnableDiscoveryClient
@SpringBootApplication
public class GatewayApplication {
    public static void main(String[] args) throws UnknownHostException {
        SpringApplication springApplication = new SpringApplication(GatewayApplication.class);
        springApplication.addListeners(new AppPropertiesPreparedListener());
        springApplication.run(args);
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = System.getProperty("server.port");
        String path = System.getProperty("server.servlet.context-path");
        log.info("\n----------------------------------------------------------\n\t" +
                "Application CLOUD is running! Access URLs:\n\t" +
                "Local: \t\thttp://:" + ip + ":" + port + path + "/\n\t" +
                "External: \thttp://" + ip + ":" + port + path + "/\n\t" +
                "----------------------------------------------------------");
    }
}
